export function createPersistedState(ctx) {    
    let currentState = (localStorage.getItem(ctx.store.$id) || '{}')
    currentState = JSON.parse(currentState)
    console.log(currentState)
    // 更新状态
    ctx.store.$patch(currentState)
    
    // 监听页面刷新
    window.onbeforeunload = () => {
      // 获取当前状态
      const currentState = ctx.store.$state
      // 存储状态
      localStorage.setItem(ctx.store.$id, JSON.stringify(currentState))
    }
}